
// 估价页面
class ValuationPage extends JPanel {
    public ValuationPage(PhoneRecycleApp app) {
        setLayout(new BorderLayout());
        setBackground(new Color(245, 245, 245));
        
        // 顶部导航
        JPanel header = PhoneRecycleApp.createHeader("估价结果", PhoneRecycleApp.HOME_PAGE, app);
        add(header, BorderLayout.NORTH);
        
        // 内容面板
        JPanel contentPanel = new JPanel();
        contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
        contentPanel.setBackground(new Color(245, 245, 245));
        contentPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        
        // 设备卡片
        JPanel deviceCard = PhoneRecycleApp.createCardPanel(null);
        
        JLabel deviceLabel = new JLabel("vivo IQOO 11Pro 16GB+512G");
        deviceLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 14));
        deviceLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
        deviceCard.add(deviceLabel);
        
        // 价格区域
        JPanel pricePanel = new JPanel();
        pricePanel.setLayout(new BoxLayout(pricePanel, BoxLayout.X_AXIS));
        pricePanel.setBackground(Color.WHITE);
        pricePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
        
        JLabel priceLabel = new JLabel("￥1519");
        priceLabel.setFont(new Font("Microsoft YaHei", Font.BOLD, 24));
        priceLabel.setForeground(new Color(255, 69, 0));
        
        JPanel timePanel = new JPanel();
        timePanel.setLayout(new BoxLayout(timePanel, BoxLayout.Y_AXIS));
        timePanel.setBackground(Color.WHITE);
        
        JLabel timeText = new JLabel("距加价结束");
        timeText.setFont(new Font("Microsoft YaHei", Font.PLAIN, 9));
        timeText.setForeground(new Color(153, 153, 153));
        
        JLabel timeValue = new JLabel("23:57:24");
        timeValue.setFont(new Font("Microsoft YaHei", Font.BOLD, 12));
        timeValue.setForeground(new Color(255, 69, 0));
        
        timePanel.add(timeText);
        timePanel.add(timeValue);
        
        pricePanel.add(priceLabel);
        pricePanel.add(Box.createHorizontalGlue());
        pricePanel.add(timePanel);
        
        deviceCard.add(pricePanel);
        
        // 价格详情
        JPanel detailPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        detailPanel.setBackground(new Color(249, 249, 249));
        detailPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        detailPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
        
        JLabel detailLabel = new JLabel("商品估价 ¥1287 + 新用户回收券 ¥232");
        detailLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 10));
        detailPanel.add(detailLabel);
        
        deviceCard.add(detailPanel);
        
        // 用户选项
        JPanel optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        optionPanel.setBackground(Color.WHITE);
        optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
        
        JLabel optionText = new JLabel("您的选项：");
        optionText.setFont(new Font("Microsoft YaHei", Font.PLAIN, 10));
        
        JLabel optionValue = new JLabel("外壳有细微使用痕迹【较少使用】");
        optionValue.setFont(new Font("Microsoft YaHei", Font.PLAIN, 10));
        optionValue.setForeground(new Color(255, 69, 0));
        
        optionPanel.add(optionText);
        optionPanel.add(optionValue);
        
        deviceCard.add(optionPanel);
        
        contentPanel.add(deviceCard);
        contentPanel.add(Box.createVerticalStrut(10));
        
        // 其他选项
        String[][] options = {
            {"若屏幕有细微划痕", "¥1394~1469"},
            {"若外壳有明显脱胶", "¥1342~1432"},
            {"若设备有进水情况", "¥13"}
        };
        
        for (String[] option : options) {
            JPanel optPanel = new JPanel();
            optPanel.setLayout(new BoxLayout(optPanel, BoxLayout.X_AXIS));
            optPanel.setBackground(Color.WHITE);
            optPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
            optPanel.setBorder(BorderFactory.createEmptyBorder(5, 20, 5, 20));
            
            JLabel optLabel = new JLabel(option[0]);
            optLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 10));
            
            JLabel priceOpt = new JLabel(option[1]);
            priceOpt.setFont(new Font("Microsoft YaHei", Font.BOLD, 10));
            priceOpt.setForeground(new Color(255, 69, 0));
            
            optPanel.add(optLabel);
            optPanel.add(Box.createHorizontalGlue());
            optPanel.add(priceOpt);
            
            contentPanel.add(optPanel);
        }
        
        contentPanel.add(Box.createVerticalStrut(10));
        
        // 回收方式
        JLabel methodTitle = new JLabel("选择回收方式");
        methodTitle.setFont(new Font("Microsoft YaHei", Font.BOLD, 12));
        methodTitle.setAlignmentX(Component.LEFT_ALIGNMENT);
        contentPanel.add(methodTitle);
        
        Object[][] methods = {
            {"门店回收", "立即拿钱", "🏢", new Color(76, 175, 80)},
            {"上门回收", "免费上门", "🚗", new Color(33, 150, 243)},
            {"邮寄回收", "顺丰取件", "📦", new Color(255, 152, 0)}
        };
        
        for (Object[] method : methods) {
            JPanel methodCard = PhoneRecycleApp.createCardPanel(null);
            methodCard.setLayout(new BoxLayout(methodCard, BoxLayout.X_AXIS));
            
            // 图标
            JPanel iconPanel = new JPanel();
            iconPanel.setPreferredSize(new Dimension(40, 40));
            iconPanel.setBackground((Color) method[3]);
            iconPanel.setLayout(new BorderLayout());
            
            JLabel iconLabel = new JLabel((String) method[2], SwingConstants.CENTER);
            iconLabel.setFont(new Font("Arial", Font.PLAIN, 18));
            iconLabel.setForeground(Color.WHITE);
            iconPanel.add(iconLabel, BorderLayout.CENTER);
            
            methodCard.add(iconPanel);
            methodCard.add(Box.createHorizontalStrut(10));
            
            // 文本
            JPanel textPanel = new JPanel();
            textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
            textPanel.setBackground(Color.WHITE);
            
            JLabel titleLabel = new JLabel((String) method[0]);
            titleLabel.setFont(new Font("Microsoft YaHei", Font.BOLD, 12));
            
            JLabel descLabel = new JLabel((String) method[1]);
            descLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 10));
            descLabel.setForeground(new Color(102, 102, 102));
            
            textPanel.add(titleLabel);
            textPanel.add(descLabel);
            
            methodCard.add(textPanel);
            methodCard.add(Box.createHorizontalGlue());
            
            // 选择按钮
            JLabel selectLabel = new JLabel("○");
            selectLabel.setFont(new Font("Arial", Font.PLAIN, 18));
            selectLabel.setForeground(new Color(204, 204, 204));
            methodCard.add(selectLabel);
            
            contentPanel.add(methodCard);
            contentPanel.add(Box.createVerticalStrut(5));
        }
        
        // 地址信息
        JPanel addressCard = PhoneRecycleApp.createCardPanel("回收地址");
        
        JLabel addressLabel = new JLabel("沈阳航空航天大学南生活区");
        addressLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
        addressLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
        
        JLabel phoneLabel = new JLabel("191****6666");
        phoneLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 10));
        phoneLabel.setForeground(new Color(102, 102, 102));
        phoneLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
        
        addressCard.add(addressLabel);
        addressCard.add(phoneLabel);
        
        contentPanel.add(addressCard);
        
        // 按钮区域
        JPanel buttonPanel = new JPanel();
        buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
        buttonPanel.setBackground(new Color(245, 245, 245));
        buttonPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
        
        JButton backButton = new JButton("返回");
        backButton.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
        backButton.setBackground(new Color(224, 224, 224));
        backButton.addActionListener(e -> app.showPage(PhoneRecycleApp.HOME_PAGE));
        
        JButton submitButton = new JButton("提交换钱");
        submitButton.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
        submitButton.setBackground(new Color(255, 69, 0));
        submitButton.setForeground(Color.WHITE);
        submitButton.addActionListener(e -> app.showPage(PhoneRecycleApp.CONFIRMATION_PAGE));
        
        buttonPanel.add(backButton);
        buttonPanel.add(Box.createHorizontalGlue());
        buttonPanel.add(submitButton);
        
        JScrollPane scrollPane = new JScrollPane(contentPanel);
        scrollPane.setBorder(BorderFactory.createEmptyBorder());
        add(scrollPane, BorderLayout.CENTER);
        add(buttonPanel, BorderLayout.SOUTH);
    }
}
